export default {
	namespaced:true,
	state:{
			address:uni.getStorageSync('address') || {},
			token:uni.getStorageSync('token') || '',
			userInfo:uni.getStorageSync('userInfo') || {}
	},
	mutations:{
		setAddress(state,obj){
			state.address = {...obj}
			this.commit('muser/saveAddressToStorage')
		},
		saveAddressToStorage(state) {
		      uni.setStorageSync('address',state.address)
		},
		setUserInfo(state,userInfo){
			state.userInfo = userInfo
			this.commit('muser/saveUserInfoToStorage')
		},
		saveUserInfoToStorage(state){
			 uni.setStorageSync('userInfo',state.userInfo)
		},
		setToken(state,str){
			state.token = str
			this.commit('muser/saveTokenToStorage')
		},
		saveTokenToStorage(state){
			uni.setStorageSync('token',state.token)
		}
	},
	getters:{
		addressStr(state) {
		  if (!state.address.provinceName) return ''
				
		  // 拼接 省，市，区，详细地址 的字符串并返回给用户
		  return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
		}
	}
}